import 'package:flutter/material.dart';
import 'package:flutter_eve_plugin/constants/font_family.dart';
import 'package:flutter_eve_plugin/constants/font_weight.dart';
import 'package:flutter_eve_plugin/model/ye_xiu/achieves/archieves_role_entity.dart';
import 'package:flutter_eve_plugin/utils/image_util.dart';
import 'package:flutter_eve_plugin/utils/screen_util.dart';

class ArchivesAttrWidget extends StatelessWidget {
  final ArchievesRoleRoleinfo info;

  const ArchivesAttrWidget({Key key, this.info}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    ArchievesRoleRoleinfoUpgradelevel upgradeLevel = info?.upgradeLevel;
    ArchievesRoleRoleinfoCardlevel cardlevel = info?.cardLevel;
    int hp, def, res, atk;
    if (upgradeLevel != null && cardlevel != null) {
      hp = upgradeLevel.hp - cardlevel.hp;
      def = upgradeLevel.def - cardlevel.def;
      res = upgradeLevel.res - cardlevel.res;
      atk = upgradeLevel.atk - cardlevel.atk;
      hp = hp > 0 ? hp : 0;
      def = def > 0 ? def : 0;
      res = res > 0 ? res : 0;
      atk = atk > 0 ? atk : 0;
    }
    return Column(
      mainAxisAlignment: MainAxisAlignment.start,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[
        Container(
          color: Color(0x2F000000),
          height: setRatio(21),
          margin: EdgeInsets.only(left: setRatio(8), right: setRatio(7)),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              Expanded(
                flex: 1,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    SizedBox(
                      width: setRatio(16),
                    ),
                    Image.asset(
                      imageUtilYeXiu('archives/icon_archivers_attr_life@3x'),
                      width: setRatio(19),
                      height: setRatio(19),
                    ),
                    Text.rich(TextSpan(
                        style: TextStyle(
                            decoration: TextDecoration.none,
                            fontFamily: FontFamily.PINGFANG,
                            fontWeight: FontWeightCustom.PF_Medium,
                            fontSize: setTextSp(11),
                            color: Color(0xFFFFFFFF)),
                        children: [
                          TextSpan(text: ' 生命 '),
                          TextSpan(
                              text: '${cardlevel?.hp ?? 0}',
                              style: TextStyle(
                                  color: Color(0xFFFD8D8E),
                                  fontSize: setTextSp(12))),
                          TextSpan(
                              text: '    +${hp ?? 0}',
                              style: TextStyle(
                                color: Color(0xFF62F488),
                              )),
                        ]))
                  ],
                ),
              ),
              Expanded(
                flex: 1,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    SizedBox(
                      width: setRatio(16),
                    ),
                    Image.asset(
                      imageUtilYeXiu(
                          'archives/icon_archivers_attr_physical_defen@3x'),
                      width: setRatio(19),
                      height: setRatio(19),
                    ),
                    Text.rich(TextSpan(
                        style: TextStyle(
                            decoration: TextDecoration.none,
                            fontFamily: FontFamily.PINGFANG,
                            fontWeight: FontWeightCustom.PF_Medium,
                            fontSize: setTextSp(11),
                            color: Color(0xFFFFFFFF)),
                        children: [
                          TextSpan(text: ' 物防 '),
                          TextSpan(
                              text: '${cardlevel.def}',
                              style: TextStyle(
                                  color: Color(0xFF93DCFF),
                                  fontSize: setTextSp(12))),
                          TextSpan(
                              text: '    +${def ?? 0}',
                              style: TextStyle(
                                color: Color(0xFF62F488),
                              )),
                        ]))
                  ],
                ),
              )
            ],
          ),
        ),
        Container(
          color: Color(0x26000000),
          height: setRatio(21),
          margin: EdgeInsets.only(left: setRatio(8), right: setRatio(7)),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              Expanded(
                flex: 1,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    SizedBox(
                      width: setRatio(16),
                    ),
                    Image.asset(
                      imageUtilYeXiu('archives/icon_archivers_attr_attack@3x'),
                      width: setRatio(19),
                      height: setRatio(19),
                    ),
                    Text.rich(TextSpan(
                        style: TextStyle(
                            decoration: TextDecoration.none,
                            fontFamily: FontFamily.PINGFANG,
                            fontWeight: FontWeightCustom.PF_Medium,
                            fontSize: setTextSp(11),
                            color: Color(0xFFFFFFFF)),
                        children: [
                          TextSpan(text: ' 攻击 '),
                          TextSpan(
                              text: '${cardlevel?.atk ?? 0}',
                              style: TextStyle(
                                  color: Color(0xFFFFAB73),
                                  fontSize: setTextSp(12))),
                          TextSpan(
                              text: '    +${atk ?? 0}',
                              style: TextStyle(
                                color: Color(0xFF62F488),
                              )),
                        ]))
                  ],
                ),
              ),
              Expanded(
                flex: 1,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    SizedBox(
                      width: setRatio(16),
                    ),
                    Image.asset(
                      imageUtilYeXiu(
                          'archives/icon_archivers_attr_mana_defen@3x'),
                      width: setRatio(19),
                      height: setRatio(19),
                    ),
                    Text.rich(TextSpan(
                        style: TextStyle(
                            decoration: TextDecoration.none,
                            fontFamily: FontFamily.PINGFANG,
                            fontWeight: FontWeightCustom.PF_Medium,
                            fontSize: setTextSp(11),
                            color: Color(0xFFFFFFFF)),
                        children: [
                          TextSpan(text: ' 法防 '),
                          TextSpan(
                              text: '${cardlevel?.res ?? 0}',
                              style: TextStyle(
                                  color: Color(0xFF56EDC4),
                                  fontSize: setTextSp(12))),
                          TextSpan(
                              text: '    +${res ?? 0}',
                              style: TextStyle(
                                color: Color(0xFF62F488),
                              )),
                        ]))
                  ],
                ),
              )
            ],
          ),
        ),
      ],
    );
  }
}
